<?php use app\commands\front\NavWidget; ?>
<?php NavWidget::begin(); ?>
<?php NavWidget::end();
$type = \Yii::$app->request->get('type', 1);
$typeName = $type == 1 ? '听力' : ($type == 2 ? '阅读' : '全科');
?>

<link rel="stylesheet" href="/cn/css/mock/index.css">
<section id="index">
    <div class="banner">
        <img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/2@2x.png" alt="">
    </div>
    <div class="tips">
        申友雅思机考模拟是完全参照雅思机考实际所设计的考试系统申友雅思机考模拟是完全参照雅思机考实际所设计的考试系统申友雅思机考模拟是完全参照雅思机考实际所设计的考试系统
    </div>
    <div class="mockBox">
        <div class="mockNav">
            <a href="/mock.html" :class="mockType==1?'on navItem':'navItem'">
                <img :src="mockType==1?'https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/5@2x.png':'https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/6@2x.png'"
                     alt="">
                单项模考
            </a>
            <a href="/mock.html?type=5" :class="mockType==2?'on navItem':'navItem'">
                <img :src="mockType==2?'https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/4@2x.png':'https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/3@2x.png'"
                     alt="">
                全套模考
            </a>
        </div>
        <div class="singleNav" v-show="mockType == 1">
            <a href="/mock.html?type=1" :class="singleType==1?'singleItem on':'singleItem'">听力模考</a>
            <a href="/mock.html?type=2" :class="singleType==2?'singleItem on':'singleItem'">阅读模考</a>
        </div>
        <!-- 听力-->
        <div class="listBox">
            <?php foreach ($data as $k => $v) { ?>

                <?php if ($v['continue'] == 0 && $v['isOver'] == 0) {//未做 ?>
                    <div class="listItem">
                        <p class="testStatus">未做</p>
                        <p class="testTitle"><?php echo $typeName ?>
<!--                            模考卷--><?php //echo \Yii::$app->params['noToStr'][$v['id']] ?><!--</p>-->
                            <?php echo $v['catName'].' '.$v['test'] ?></p>
                        <div class="linkBox">
                            <a href="/mock/guide.html?type=<?php echo $type ?>&cate=<?php echo $v['id'] ?>" class="start">开始模考</a>
                        </div>
                        <div class="testData">
                            <p>平均耗时：<?php echo $v['avgTime'] ?></p>

                            <p><img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/1@2x.png"
                                    alt=""><?php echo $v['number'] ?></p>
                        </div>
                    </div>
                <?php } ?>
                <!--                --><?php //if ($v['continue'] == 1 && $v['isOver'] == 0) { //中断?>
                <!--                    <div class="listItem">-->
                <!--                        <p class="continueStatus">--><?php //echo $v['time'] ?><!--</p>-->
                <!--                         <p class="testTitle">--><?php //echo $typeName?><!--模考卷--><?php //echo \Yii::$app->params['noToStr'][$v['id']] ?><!--</p>-->
                <!--                        <div class="linkBox">-->
                <!--                            <a href="/mock/guide.html?type=--><?php //echo $type ?><!--&cate=--><?php //echo $v['id']?><!--" class="reset">重新模考</a>-->
                <!--                            <a href="/cn/mock/--><?php //echo $v['startType']?><!--&type=5&cate=--><?php //echo $v['id']?><!--&contuniu=1" class="start">继续模考</a>-->
                <!--                        </div>-->
                <!--                        <div class="testData">-->
                <!--                            <p>平均耗时：--><?php //echo $v['avgTime'] ?><!--</p>-->
                <!---->
                <!--                            <p><img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/1@2x.png"-->
                <!--                                    alt="">--><?php //echo $v['number'] ?><!--</p>-->
                <!--                        </div>-->
                <!--                    </div>-->
                <!--                --><?php //} ?>
                <?php if (($v['continue'] == 2 && $v['isOver'] == 1) || ($v['continue'] == 1 && $v['isOver'] == 0)) {//未完成 ?>
                    <div class="listItem">
                        <p class="continueStatus">未完成</p>
                        <p class="testTitle"><?php echo $typeName ?>
<!--                            模考卷--><?php //echo \Yii::$app->params['noToStr'][$v['id']] ?><!--</p>-->
                            <?php echo $v['catName'].' '.$v['test'] ?></p>
                        <div class="linkBox">
                            <a href="/mock/guide.html?type=<?php echo $type ?>&cate=<?php echo $v['id'] ?>" class="reset">重新模考</a>
                            <a href="/mock/result.html?type=<?php echo $type ?>&cate=<?php echo $v['id'] ?>"
                               class="start">查看结果</a>
                        </div>
                        <div class="testData">
                            <p>平均耗时：<?php echo $v['avgTime'] ?></p>

                            <p><img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/1@2x.png"
                                    alt=""><?php echo $v['number'] ?></p>
                        </div>
                    </div>
                <?php } ?>
                <?php if ($v['continue'] == 0 && $v['isOver'] == 1) {//完成 ?>
                    <div class="listItem">
                        <p class="successStatus">完成</p>
                        <p class="testTitle"><?php echo $typeName ?>
<!--                            模考卷--><?php //echo \Yii::$app->params['noToStr'][$v['id']] ?><!--</p>-->
                            <?php echo $v['catName'].' '.$v['test'] ?></p>
                        <div class="linkBox">
                            <a href="/mock/guide.html?type=<?php echo $type ?>&cate=<?php echo $v['id'] ?>" class="reset">重新模考</a>
                            <a href="/mock/result.html?type=<?php echo $type ?>&cate=<?php echo $v['id'] ?>"
                               class="start">查看结果</a>
                        </div>
                        <div class="testData">
                            <p>平均耗时：<?php echo $v['avgTime'] ?></p>

                            <p><img src="https://file.viplgw.cn/ui/thinku-ielts-new/images/mock/1@2x.png"
                                    alt=""><?php echo $v['number'] ?></p>
                        </div>
                    </div>
                <?php } ?>

            <?php } ?>

        </div>
    </div>
    <!-- 首次模考弹窗-->
    <?php if ($isInfo == false) { ?>
        <div class="collectionBox">
            <div class="collection" style="height: 408px">
                <p class="infoTitle">确认信息</p>
                <div class="infoItem">
                    <p>我的ID：&nbsp;&nbsp;&nbsp;<?php echo $user['userName']?></p>
                </div>
<!--                <div class="infoItem">-->
<!--                    <p><span>*</span>我的电话：</p>-->
<!--                    <el-input size="middle" style="width: 330px" v-model="phone"-->
<!--                              placeholder="请输入你的电话"></el-input>-->
<!--                </div>-->
                <div class="infoItem">
                    <p>我的微信：</p>
                    <el-input size="middle" style="width: 330px" v-model="wechat"
                              placeholder="请输入你的微信"></el-input>
                </div>
                <div class="infoItem">
                    <p>目标分数：</p>
                    <el-select v-model="grade" size="middle" style="width: 330px" placeholder="请选择">
                        <el-option
                                v-for="(item,index) in gradeArry"
                                :key="index"
                                :label="item"
                                :value="item">
                        </el-option>
                    </el-select>
                </div>
                <div class="submit" style="cursor: pointer" @click="submitData">进入考场</div>
            </div>
        </div>
    <?php } ?>
</section>

<script>
    new Vue({
        el: '#index',
        data() {
            return {
                mockType: <?php echo $type != 5 ? 1 : 2?>,//1 单科  2全科
                singleType:<?php echo $type?>,//1 听力  2阅读
                phone: '',
                wechat: '',
                gradeArry: ['6', '6.5', '7', '7.5', '8', '8.5'],
                grade: '6',
            }
        },
        created() {

        },

        methods: {
            submitData() {
                let that = this
                // if (this.phone == '' || this.wechat == '') {
                //     alert('信息不全！')
                //     return
                // }
                $.post('/cn/mock/get-info', {
                    wx: that.wechat,
                    score: that.grade,
                }, function (res) {
                    if (res.code == 1) {
                        $('.collectionBox').hide()
                    }else {
                        alert(res.message)
                    }
                }, 'json')
            },
        },
    });
</script>
